﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MN.Framework.Common;
using MN.Framework.MetaData;

namespace TZ.Common
{
    [EntityHeader("خرید ها")]
    [AssociatedWith(typeof(Person), "PersonRef", MN.Framework.MetaData.AssociationType.OneToMany)]
    public partial class Purchase : BaseEntity
    {        
        public override void GetColumns(List<ColumnInfo> columns)
        {
            columns.Add(new NumericColumnInfo("ID", "شناسه", true));
            columns.Add(new TextColumnInfo("Title", "عنوان"));
            columns.Add(new NumericColumnInfo("Price", "هزینه", NumericType.FloatingPoint, typeof(double)));
            columns.Add(new ReferenceColumnInfo("PersonRef", "فروشنده"));
            columns.Add(new TextColumnInfo("Description", "توضیحات",ColumnSize.XLarg));
        }
        public override void RegisterValidationRules()
        {
            base.RegisterValidationRules();
            base.AddRule("Title", new RequiredValidationRule());
            base.AddRule("Price", new RequiredValidationRule());
            base.AddRule("Price", new LogicalValidationRule(LogicalOperator.GreaterThanOrEqual, "Price"));
        }
    }
}
